﻿Imports Phila
Imports Phila.Sql
Imports Phila.CommonClasses
Imports Telerik.WebControls

Public Class ViewHotelCategory
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Dim strSql As String
        'strSql = "select * from ptn_HotelCategory order by Id desc"
        'Fill_Grid_Bind(gvHotelCat, strSql)
    End Sub

    'Private Sub gvRoomCat_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gvHotelCat.RowEditing
    '    Dim Id As Integer = gvHotelCat.Rows(e.NewEditIndex).Cells(0).Text
    '    Response.Redirect("EditHotelCategory.aspx?id=" & ID)
    'End Sub

    Protected Sub radGrid_DeleteCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) Handles radGrid.DeleteCommand
        Dim ID As String = (CType(e.Item, GridDataItem)).OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ID").ToString
        Try
            Dim txt As Array
            txt = RetriveData("select Id from ptn_Hotels where CategoryId=" & ID, 0)
            If txt(0) Is Nothing Then
                Insert_Update_Delete_Record("delete from ptn_HotelCategory where id=" & ID)
            Else
                radGrid.Controls.Add(New LiteralControl(("<spa class=""error"">Unable to Delete Record. Reason: This record being used by the hotel</span>")))
                lblMsg.Text = "Unable to Delete Record. Reason: This record being used by the hotel"
                lblMsg.ForeColor = Drawing.Color.Red
            End If
        Catch ex As Exception
            'radGrid.Controls.Add(New LiteralControl(("Unable to Delete Record. Reason: " + ex.Message)))
            lblMsg.Text = "Unable to Delete Record. Reason: " + ex.Message
            lblMsg.ForeColor = Drawing.Color.Red
            e.Canceled = True
        End Try
    End Sub

    Protected Sub radGrid_NeedDataSource(ByVal source As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles radGrid.NeedDataSource
        Fill_Grid(radGrid, "select * from ptn_HotelCategory order by Name")
    End Sub

End Class